package com.qf.controller;

import com.qf.constant.RedisConstant;
import com.qf.dto.ResultBean;
import com.qf.service.EmailRegisterService;
import com.qf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 * User: dong
 * Date: 2020/3/13
 */
@Controller
@RequestMapping("email")
public class EmailController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private EmailRegisterService service;

    //邮件激活校验
    @RequestMapping("active")
    @ResponseBody
    public ResultBean actionAccount(String uuid){
        //生成redisKey
        String redisKey = StringUtil.getRedisKey(RedisConstant.REGISTER_EMAIL,uuid);
        //获取邮箱地址
        String email = (String) redisTemplate.opsForValue().get(redisKey);
        //激活用户信息
        return service.emailActive(email);
    }
}
